﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Shop.Page.Models;
using PetaPoco;

namespace Shop.Page.Repositories
{

    /// <summary>
    /// 数据访问层
    /// </summary>
    public class OtherAccess
    {
        private Database DB = new Database("ConnString");
        /// <summary>
        /// 获取其他信息
        /// </summary>
        /// <param name="Type"></param>
        /// <returns></returns>
        public IList<Other> GetOtherInfo()
        {
            Sql sql = Sql.Builder.Append("select * from Shop_Other");
            return DB.Fetch<Other>(sql);
        }
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="oinfo"></param>
        /// <returns></returns>
        public int UpdateOtherInfo(Other oinfo)
        {
            Sql sql = Sql.Builder.Append("update Shop_Other set Value = @0 where Type = @1", oinfo.Value, oinfo.Type);
            return DB.Execute(sql);

        }
        /// <summary>
        /// 根据type获取信息
        /// </summary>
        /// <param name="Type"></param>
        /// <returns></returns>
        public Other GetOtherInfo(int Type)
        {
            Sql sql = Sql.Builder.Append("select * from Shop_Other where type = @0", Type);
            return DB.FirstOrDefault<Other>(sql);
        }
    }
}
